package com.hanscan.gui;

import com.hanscan.util.language.LanguageConfig;
import com.icesoft.faces.component.ext.HtmlCommandButton;
import com.icesoft.faces.component.ext.HtmlInputText;
import com.icesoft.faces.component.ext.HtmlOutputLabel;
import com.icesoft.faces.component.ext.HtmlPanelGrid;
import com.icesoft.faces.component.selectinputdate.SelectInputDate;
import com.sun.rave.web.ui.appbase.AbstractFragmentBean;
import javax.faces.FacesException;
import javax.faces.event.ActionEvent;



public class ManagementReports extends AbstractFragmentBean
{

    private HtmlOutputLabel labelTitle = new HtmlOutputLabel();
    private HtmlOutputLabel labelTitleDetail = new HtmlOutputLabel();
    private HtmlOutputLabel labelFilterByName1 = new HtmlOutputLabel();
    private HtmlOutputLabel labelFilterBySurname1 = new HtmlOutputLabel();
    private HtmlOutputLabel labelFilterBySurname2 = new HtmlOutputLabel();
    private HtmlOutputLabel labelFilterByNumber = new HtmlOutputLabel();
    private HtmlOutputLabel labelEntry = new HtmlOutputLabel();
    private HtmlOutputLabel labelDeparture = new HtmlOutputLabel();
    private HtmlOutputLabel labelFilterByLocation = new HtmlOutputLabel();

    private HtmlCommandButton btnSearchOrder = new HtmlCommandButton();

    private HtmlPanelGrid containerFilter= new HtmlPanelGrid();

    private HtmlInputText inputTextFilterByName = new HtmlInputText();
    private HtmlInputText inputTextFilterBySurname1 = new HtmlInputText();
    private HtmlInputText inputTextFilterBySurname2 = new HtmlInputText();
    private HtmlInputText inputTextFilterByNumber = new HtmlInputText();
    private HtmlInputText inputTextFilterByLocation = new HtmlInputText();

    private SelectInputDate selectInputDateIn = new SelectInputDate();
    private SelectInputDate selectInputDateOut = new SelectInputDate();

    private String idioma;
    final String LANGUAGE_ES = "es";
    final String COUNTRY_ES = "ES";
    final String LANGUAGE_EN = "en";
    final String COUNTRY_US = "US";


    private void _init() throws Exception
    {
        idioma = LANGUAGE_ES;
        if (idioma.equals(LANGUAGE_ES))
        {
            getSessionBean1().getSessionBeanLanguage().changeLanguage(LANGUAGE_ES, COUNTRY_ES);
        }
        else if (idioma.equals(LANGUAGE_EN))
        {
            getSessionBean1().getSessionBeanLanguage().changeLanguage(LANGUAGE_EN, COUNTRY_US);
        }
        loadLanguage(getSessionBean1().getSessionBeanLanguage());
    }


    public ManagementReports()
    {   
    }

    /**
     *
     * @param languageConfig
     */
    protected void loadLanguage(LanguageConfig languageConfig)
    {
        labelTitle.setValue(languageConfig.getProperty("Buscar"));
        labelTitleDetail.setValue(getSessionBean1().getSessionBeanLanguage().getProperty("Password"));
        btnSearchOrder.setValue(languageConfig.getProperty("Buscar"));
        labelFilterByName1.setValue(languageConfig.getProperty("Nombre"));
        labelFilterBySurname1.setValue(languageConfig.getProperty("Primer_Apellido"));
        labelFilterBySurname2.setValue(languageConfig.getProperty("Segundo_Apellido"));
        labelFilterByNumber.setValue(languageConfig.getProperty("N_Usuario"));
        labelFilterByLocation.setValue(languageConfig.getProperty("Localizacion"));
        labelEntry.setValue(languageConfig.getProperty("Inicio_Fecha_Compra"));
        labelDeparture.setValue(languageConfig.getProperty("Fin_Fecha_Compra"));



//        //Mensajes
//        popUpHeaderError = languageConfig.getProperty("Error");
//        popUpHeaderOk = languageConfig.getProperty("Msj_Operacion_Correcta");
//        popUpHeaderNotice = languageConfig.getProperty("Aviso");
//        popUpMessageError = languageConfig.getProperty("Msj_Producido_Error");
//        popUpMessageErrorList=languageConfig.getProperty("Msj_Problemas_Cargar_Listas");
//        popUpMessageErrorNonexistentOrders = languageConfig.getProperty("Msj_No_Pedido_Criterio_Busqueda");
//        popUpMessageCommError = languageConfig.getProperty("Msj_Error_Comunicaciones");
//
//
//        //Tablas
//        nameHeader = languageConfig.getProperty("Nombre");
//        surname1Header = languageConfig.getProperty("Primer_Apellido");
//        surname2Header = languageConfig.getProperty("Segundo_Apellido");
//        clientNumberHeader=languageConfig.getProperty("N_Usuario");
//        purchaseDateHeader=languageConfig.getProperty("Fecha_Compra");
//        detailsHeader=languageConfig.getProperty("Detalles_del_Pedido");
//        detailsFooter=languageConfig.getProperty("Show_own_details");
//        locationHeader=languageConfig.getProperty("Localizacion");
//
//        itemHeader=languageConfig.getProperty("Articulo");
//        pricePerItemHeader=languageConfig.getProperty("Precio_por_Unidad");
//        vatPerItemHeader=languageConfig.getProperty("Label_VAT");
//        unitsHeader=languageConfig.getProperty("Unidades");
//        subtotalHeader=languageConfig.getProperty("Subtotal");
//        outputTextTotalPrice.setValue(languageConfig.getProperty("Precio_Total"));
//        totalPriceHeader=languageConfig.getProperty("Precio_Total");
//        btnBackToSearch.setValue(languageConfig.getProperty("Atras"));
//        dateOfPurchaseText=languageConfig.getProperty("Date_Of_Purchase");
    }

    /**
     *
     * @param e
     * @return
     */
    public String btnSearchOrder_action(ActionEvent e)
    {
        return null;
    }

    @Override
    public void init()
    {
        super.init();
        try
        {
            _init();
        } 
        catch (Exception e)
        {
            log("Page1 Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
    }

    @Override
    public void destroy()
    {
    }

///////////////////////////////////////////////////////////////////////////
/////////////       GETTERS Y SETTERS
///////////////////////////////////////////////////////////////////////////

    protected RequestBean1 getRequestBean1()
    {
        return (RequestBean1) getBean("RequestBean1");
    }

    protected SessionBean1 getSessionBean1()
    {
        return (SessionBean1) getBean("SessionBean1");
    }

    protected ApplicationBean1 getApplicationBean1()
    {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }

    public HtmlCommandButton getBtnSearchOrder() {
        return btnSearchOrder;
    }

    public void setBtnSearchOrder(HtmlCommandButton btnSearchOrder) {
        this.btnSearchOrder = btnSearchOrder;
    }

    public HtmlPanelGrid getContainerFilter() {
        return containerFilter;
    }

    public void setContainerFilter(HtmlPanelGrid containerFilter) {
        this.containerFilter = containerFilter;
    }

    public HtmlInputText getInputTextFilterByName() {
        return inputTextFilterByName;
    }

    public void setInputTextFilterByName(HtmlInputText inputTextFilterByName) {
        this.inputTextFilterByName = inputTextFilterByName;
    }

    public HtmlInputText getInputTextFilterByNumber() {
        return inputTextFilterByNumber;
    }

    public void setInputTextFilterByNumber(HtmlInputText inputTextFilterByNumber) {
        this.inputTextFilterByNumber = inputTextFilterByNumber;
    }

    public HtmlInputText getInputTextFilterBySurname1() {
        return inputTextFilterBySurname1;
    }

    public void setInputTextFilterBySurname1(HtmlInputText inputTextFilterBySurname1) {
        this.inputTextFilterBySurname1 = inputTextFilterBySurname1;
    }

    public HtmlInputText getInputTextFilterBySurname2() {
        return inputTextFilterBySurname2;
    }

    public void setInputTextFilterBySurname2(HtmlInputText inputTextFilterBySurname2) {
        this.inputTextFilterBySurname2 = inputTextFilterBySurname2;
    }

    public HtmlOutputLabel getLabelDeparture() {
        return labelDeparture;
    }

    public void setLabelDeparture(HtmlOutputLabel labelDeparture) {
        this.labelDeparture = labelDeparture;
    }

    public HtmlOutputLabel getLabelEntry() {
        return labelEntry;
    }

    public void setLabelEntry(HtmlOutputLabel labelEntry) {
        this.labelEntry = labelEntry;
    }

    public HtmlOutputLabel getLabelFilterByLocation() {
        return labelFilterByLocation;
    }

    public void setLabelFilterByLocation(HtmlOutputLabel labelFilterByLocation) {
        this.labelFilterByLocation = labelFilterByLocation;
    }

    public HtmlOutputLabel getLabelFilterByName1() {
        return labelFilterByName1;
    }

    public void setLabelFilterByName1(HtmlOutputLabel labelFilterByName1) {
        this.labelFilterByName1 = labelFilterByName1;
    }

    public HtmlOutputLabel getLabelFilterByNumber() {
        return labelFilterByNumber;
    }

    public void setLabelFilterByNumber(HtmlOutputLabel labelFilterByNumber) {
        this.labelFilterByNumber = labelFilterByNumber;
    }

    public HtmlOutputLabel getLabelFilterBySurname1() {
        return labelFilterBySurname1;
    }

    public void setLabelFilterBySurname1(HtmlOutputLabel labelFilterBySurname1) {
        this.labelFilterBySurname1 = labelFilterBySurname1;
    }

    public HtmlOutputLabel getLabelFilterBySurname2() {
        return labelFilterBySurname2;
    }

    public void setLabelFilterBySurname2(HtmlOutputLabel labelFilterBySurname2) {
        this.labelFilterBySurname2 = labelFilterBySurname2;
    }

    public HtmlOutputLabel getLabelTitle() {
        return labelTitle;
    }

    public void setLabelTitle(HtmlOutputLabel labelTitle) {
        this.labelTitle = labelTitle;
    }

    public HtmlOutputLabel getLabelTitleDetail() {
        return labelTitleDetail;
    }

    public void setLabelTitleDetail(HtmlOutputLabel labelTitleDetail) {
        this.labelTitleDetail = labelTitleDetail;
    }

    public SelectInputDate getSelectInputDateIn() {
        return selectInputDateIn;
    }

    public void setSelectInputDateIn(SelectInputDate selectInputDateIn) {
        this.selectInputDateIn = selectInputDateIn;
    }

    public SelectInputDate getSelectInputDateOut() {
        return selectInputDateOut;
    }

    public void setSelectInputDateOut(SelectInputDate selectInputDateOut) {
        this.selectInputDateOut = selectInputDateOut;
    }

    public HtmlInputText getInputTextFilterByLocation() {
        return inputTextFilterByLocation;
    }

    public void setInputTextFilterByLocation(HtmlInputText inputTextFilterByLocation) {
        this.inputTextFilterByLocation = inputTextFilterByLocation;
    }

}
